home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / driverss.zip / NI9210.ASM < prev    next >
Assembly Source File  |  1991-01-26  |  7KB  |  285 lines

  1. version    equ    0
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210, by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;Updated to version 1.08 Feb. 17, 1989 by Russell Nelson.
  9. ;Updated to support 1500 byte MTU April 27, 1989 By Brad Clements.
  10. ;Mangled to become a NI9210 driver, September 1989 by Russell Nelson
  11.  
  12. ;  Copyright, 1988, 1989, Russell Nelson
  13.  
  14. ;   This program is free software; you can redistribute it and/or modify
  15. ;   it under the terms of the GNU General Public License as published by
  16. ;   the Free Software Foundation, version 1.
  17. ;
  18. ;   This program is distributed in the hope that it will be useful,
  19. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;   GNU General Public License for more details.
  22. ;
  23. ;   You should have received a copy of the GNU General Public License
  24. ;   along with this program; if not, write to the Free Software
  25. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. code    segment    word public
  28.     assume    cs:code, ds:code
  29.  
  30. ;
  31. ;  Equates for controlling the MICOM board
  32. ;
  33. ;  I/O addresses, writing anything in AL trips these gates
  34. ;
  35. ;  First six addresses are the EPROM board Ether address (read)
  36. ;
  37. IORESET    EQU    0            ; reset the board
  38. IOCA    EQU    2            ; execute command which is in SCB
  39. IODIS    EQU    4            ; disable network connect
  40. IOENA    EQU    6            ; enable network
  41.  
  42. ;
  43. ;  Data segment
  44. ;
  45.  
  46.     public    int_no
  47. int_no        db    2,0,0,0        ; interrupt number. 
  48. io_addr        dw    0360h,0        ; I/O address for card (pos)
  49. base_addr    dw      0d000h,0    ; base segment for board (pos)
  50.  
  51.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  52. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  53. driver_type    db    11        ;from the packet spec
  54. driver_name    db    "NI9210",0    ;name of the driver.
  55. driver_function    db    2
  56. parameter_list    label    byte
  57.     db    1    ;major rev of packet driver
  58.     db    9    ;minor rev of packet driver
  59.     db    14    ;length of parameter list
  60.     db    EADDR_LEN    ;length of MAC-layer address
  61.     dw    GIANT    ;MTU, including MAC headers
  62.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  63.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  64.     dw    0    ;(# of successive xmits) - 1
  65. int_num    dw    0    ;Interrupt # to hook for post-EOI
  66.             ;processing, 0 == none,
  67.  
  68. enable_network:
  69. ;  connect to network
  70.     loadport
  71.     setport    IOENA            ; enable network
  72.     out    dx,al            ; any al value
  73.     ret
  74.  
  75.  
  76. reset_586:
  77. ;  Reset the chip
  78.     loadport
  79.     setport    IORESET
  80.     out    dx,al
  81.     ret
  82.  
  83.  
  84.     public    get_address
  85. get_address:
  86. ;get the address of the interface.
  87. ;enter with es:di -> place to get the address, cx = size of address buffer.
  88. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  89.     assume    ds:code
  90.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  91.     jb    get_address_2
  92.     mov    cx,EADDR_LEN
  93.     mov    dx,io_addr        ; Get our IO base address.
  94.     cld
  95. get_address_1:
  96.     in    al,dx            ; get a byte of the eprom address
  97.     stosb                ; put it away
  98.     add    dx,2            ; next register
  99.     loop    get_address_1        ; go back for rest
  100.     mov    cx,EADDR_LEN
  101.     clc
  102.     ret
  103. get_address_2:
  104.     stc
  105.     ret
  106.  
  107.  
  108. doca:
  109. ;we may be called from places in which ds is unknown.
  110.     assume    ds:nothing
  111.     loadport
  112.     setport    IOCA
  113.     out    dx,al            ; send it
  114.     ret
  115.     assume    ds:code
  116. ;yet, we really should assume ds==code for the rest of this stuff.
  117.  
  118. ;
  119. ; Here we include the code that is common between 82586 implementations.
  120. ; Everything above this is resident.
  121.     include    82586.asm
  122. ; Everything below this is discarded upon installation.
  123.  
  124.     public    usage_msg
  125. usage_msg    db    "usage: ni9210 [-n] [-d] [-w] <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  126.  
  127.     public    copyright_msg
  128. copyright_msg    db    "Packet driver for the MICOM-Interlan NI9210, version ",'0'+majver,".",'0'+version,".",'0'+i82586_version,CR,LF
  129.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  130.  
  131. IRQ_MASK    equ    06h
  132. IRQ_TABLE    db    9            ; Interrupt Value 0
  133.         db    10            ; Interrupt Value 1
  134.         db    11            ; Interrupt Value 2
  135.         db    3            ; Interrupt Value 3
  136.  
  137. check_board:
  138.     mov    SCP,0            ; 16 bit bus type in scb.
  139.  
  140. ;The following code to read the POS registers is courtesy of Racal-Interlan.
  141.  
  142. ; channel selector resides at io 96h
  143. ; POS register base is at io 100h
  144. ; 9210 ID is 0DF0Fh
  145.  
  146. ; search thro' the slots for a 9210 card
  147.     mov    cx, 8            ; for all channels(slots)
  148.  
  149. ; channel select value for slots 0,1,2.. is 8,9,A etc
  150. ; start with slot 0, and then 7,6,5,4,3,2,1
  151. get_05:
  152.     mov    ax, cx            ; channel number
  153.     or    ax, 08h            ; reg. select value
  154.     mov    dx, 96h            ; channel select register
  155.     out    dx, al            ; select channel
  156.  
  157. ; read adapter id
  158.     mov    dx, 100h
  159.     in    al, dx            ; adapter id - ms byte
  160.     mov    ah, al
  161.     inc    dx
  162.     in    al, dx            ; adapter id - ls byte
  163.  
  164. ; Check if 9210
  165.     cmp    ax, 0DF0Fh
  166.     je    get_10
  167.     loop    get_05
  168.  
  169.     mov    dx,offset no_9210_msg
  170.     jmp    error
  171.  
  172. get_10:
  173. ; found our Adapter
  174.  
  175. ; Get Ni9210 I/O Address ( read POS Register 1 )
  176.     xor    ax,ax
  177.     mov    dx,103h
  178.     in    al,dx
  179.     xor    ah,ah
  180.     mov    cl,5
  181.     shl    ax,cl
  182.     mov    io_addr,ax
  183.  
  184. ; Get Ni9210 IRQ ( read POS Register 0 )
  185.     mov    dx,102h
  186.     in    al,dx
  187.     mov    bl,al
  188.     and    bx,IRQ_MASK
  189.     shr    bx,1
  190.     mov    al,IRQ_TABLE[bx]
  191.     mov    int_no,al
  192.  
  193. ; Get Memory Address ( read POS Registers 2 and 3 )
  194.     mov    dx,105h
  195.     in    al,dx
  196.     mov    ah,al
  197.     dec    dx
  198.     in    al,dx
  199.     and    ax,3fe0h
  200.     mov    cl,5
  201.     shl    ax,cl
  202.     mov    base_addr,ax
  203.  
  204.     mov    dx, 102h
  205.     in    al,dx
  206.     or    al,1            ;enable the card.
  207.     out    dx,al
  208.  
  209.     mov    dx, 96h            ;deselect the card.
  210.     xor    al,al
  211.     out    dx,al
  212.  
  213.     mov    dx,io_addr        ; i/o address
  214.     add    dx,EADDR_LEN*2        ; look past the ethernet address.
  215.     in    al,dx
  216.     mov    bl,al            ; assemble pattern to check
  217.     add    dx,2
  218.     in    al,dx
  219.     mov    bh,al
  220.     cmp    bx,05500h        ; pattern known to be there in ROM
  221.     jz    have_9210_io
  222.     pop    dx            ;drop our return address
  223.     mov    dx,offset no_9210_io_msg
  224.     jmp    error
  225. have_9210_io:
  226.  
  227.     mov    ax,base_addr
  228.     mov    cx,2000h        ;test only what we are going to use.
  229.     call    memory_test
  230.     jz    have_9210_mem
  231.     pop    dx            ;drop our return address
  232.     mov    dx,offset no_9210_mem_msg
  233.     jmp    error
  234. have_9210_mem:
  235.     ret
  236.  
  237. no_9210_msg    db    "No 9210 found.",CR,LF,'$'
  238.  
  239.  
  240. no_9210_io_msg    db    "No 9210 found at that I/O address.",CR,LF,'$'
  241. no_9210_mem_msg    db    "No 9210 found at that memory address.",CR,LF,'$'
  242.  
  243.     public    parse_args
  244. parse_args:
  245.     mov    di,offset int_no
  246.     call    get_number
  247.     mov    di,offset io_addr
  248.     call    get_number
  249.     mov    di,offset base_addr
  250.     call    get_number
  251.     clc
  252.     ret
  253.  
  254.  
  255. int_no_name    db    "Interrupt number ",'$'
  256. io_addr_name    db    "I/O port ",'$'
  257. base_addr_name    db    "Memory address ",'$'
  258.  
  259.  
  260.     public    print_parameters
  261. print_parameters:
  262.     mov    di,offset int_no
  263.     mov    dx,offset int_no_name
  264.     call    print_number
  265.     mov    di,offset io_addr
  266.     mov    dx,offset io_addr_name
  267.     call    print_number
  268.     mov    ax,memory_begin
  269.     mov    cl,4
  270.     shr    ax,cl
  271.     add    base_addr,ax
  272.     push    ax
  273.     mov    di,offset base_addr
  274.     mov    dx,offset base_addr_name
  275.     call    print_number
  276.     pop    ax
  277.     sub    base_addr,ax
  278.     ret
  279.  
  280.     include    memtest.asm
  281.  
  282. code    ends
  283.  
  284.     end
  285.